package com.sky.api.client.user;

import com.sky.entity.AddressBook;
import com.sky.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "addressBook-server")
public interface AddressBookClient {

    /**
     * 查询当前登录用户的所有地址信息
     *
     * @return
     */
    @GetMapping("/user/addressBook/list")
    @ApiOperation("查询当前登录用户的所有地址信息")
    Result<List<AddressBook>> list();

    /**
     * 新增地址
     *
     * @param addressBook
     * @return
     */
    @PostMapping("/user/addressBook")
    Result save(@RequestBody AddressBook addressBook) ;

    @GetMapping("/user/addressBook/{id}")
    Result<AddressBook> getById(@PathVariable Long id) ;

    /**
     * 根据id修改地址
     *
     * @param addressBook
     * @return
     */
    @PutMapping("/user/addressBook")
    Result update(@RequestBody AddressBook addressBook) ;

    /**
     * 设置默认地址
     *
     * @param addressBook
     * @return
     */
    @PutMapping("/user/addressBook/default")
    Result setDefault(@RequestBody AddressBook addressBook);

    /**
     * 根据id删除地址
     *
     * @param id
     * @return
     */
    @DeleteMapping("/user/addressBook")
    Result deleteById(Long id) ;

    /**
     * 查询默认地址
     */
    @GetMapping("/user/addressBook/default")
    Result<AddressBook> getDefault() ;

}
